﻿namespace PugLib.Extensions
{
	using System;
	using System.Collections.Generic;
	using System.Diagnostics.CodeAnalysis;

	public static class PipeExtensions
	{
		public static TOut Transform<T, TOut>(this T self, Func<T, TOut> selector)
		{
			return selector(self);
		}

		public static IEnumerable<T> Process<T>(this IEnumerable<T> self, Action<T> action)
		{
			foreach (T item in self)
			{
				action(item);
				yield return item;
			}
		}

		[SuppressMessage("Microsoft.Performance", "CA1804:RemoveUnusedLocals", MessageId = "item", Justification = "forcing iteration")]
		public static void Execute<T>(this IEnumerable<T> self)
		{
			foreach (T item in self)
			{
			}
		}
	}
}